# _*_encoding:utf-8 _*_
"""Education URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.9/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
# from django.contrib import admin
from django.views.generic import TemplateView
import xadmin
from django.views.static import serve

from users import views as users_view
from Education.settings import MEDIA_ROOT#, STATIC_ROOT

urlpatterns = [
    url(r'^xadmin/', xadmin.site.urls),
    url(r'^$', users_view.IndexView.as_view(), name='index'),
    url(r'^login/$', users_view.LoginView.as_view(), name='login'),
    url(r'^logout/$', users_view.LogoutView.as_view(), name='logout'),
    url(r'^register/$', users_view.RegisterView.as_view(), name='register'),
    url(r'^active/(?P<active_code>.*)/$', users_view.ActiveView.as_view(), name='user_active'),
    url(r'^captcha/', include('captcha.urls')),
    url(r'^forget/$', users_view.ForgetPwdView.as_view(), name='forget_pwd'),
    url(r'^reset/(?P<reset_code>.*)/$', users_view.ResetView.as_view(), name='reset_pwd'),
    # 配置上传文件的访问处理函数
    url(r'^media/(?P<path>.*)$', serve, {'document_root': MEDIA_ROOT}),
    # 课程机构url配置
    url(r'^org/', include('organization.urls', namespace='org')),
    # 课程url配置
    url(r'^course/', include('courses.urls', namespace='course')),
    # 用户中心url配置
    url(r'^users/', include('users.urls', namespace='users')),

    # 处理静态文件
    # url(r'^static/(?P<path>.*)$', serve, {'document_root': STATIC_ROOT}),
]

# 全局404页面配置
handler404 = 'users.views.page_not_found'
handler500 = 'users.views.page_error'
